/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package samoloty.view;

import Utils.MyOwnFocusTraversalPolicy;
import Utils.TextFieldFilter;
import com.sun.jmx.remote.util.OrderClassLoaders;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Point;
import java.util.Vector;
import javax.swing.JLabel;
import javax.swing.SwingConstants;

/**
 *
 * @author borysfan
 */
public class SiPanel extends ContentPanel implements IContentPanel {

    public int identity = 5;
    private MyLabel paxWeight;
    private MyLabel deadLoads;
    private MyLabel zfwLimits;
    private MyLabel pantry;
    private MyTextField textField1;
    private MyTextField textField2;
    private MyTextField textField3;

    public SiPanel() {
        super();
        initPanel();
    }

    private void initPanel() {
        setLayout(null);
        paxWeight = new MyLabel("PAX WEIGHT USED: ", MyLabel.BOLD);
        paxWeight.setPreferredSize(new Dimension(500,20));
        paxWeight.setHorizontalAlignment(SwingConstants.LEFT);

        deadLoads = new MyLabel("DEADLOADS IN HOLDS TTL: ", MyLabel.BOLD);
        deadLoads.setPreferredSize(new Dimension(500,20));
        deadLoads.setHorizontalAlignment(SwingConstants.LEFT);

        zfwLimits = new MyLabel("ZFW LIMITS: ", MyLabel.BOLD);
        zfwLimits.setPreferredSize(new Dimension(500,20));
        zfwLimits.setHorizontalAlignment(SwingConstants.LEFT);

        pantry = new MyLabel("PANTRY: ", MyLabel.BOLD);
        pantry.setPreferredSize(new Dimension(500,20));
        pantry.setHorizontalAlignment(SwingConstants.LEFT);
        

        textField1 = new MyTextField(30);
        textField2 = new MyTextField(30);
        textField3 = new MyTextField(30);
        /*
        paxWeight.setAlignmentX(MyLabel.RIGHT_ALIGNMENT);
        deadLoads.setAlignmentX(MyLabel.RIGHT_ALIGNMENT);
        zfwLimits.setAlignmentX(MyLabel.RIGHT_ALIGNMENT);
        pantry.setAlignmentX(MyLabel.RIGHT_ALIGNMENT);
         */
        textField1.setFieldFilter(new TextFieldFilter(TextFieldFilter.SPEC_UP_ALP+" ", 30, true));
        textField2.setFieldFilter(new TextFieldFilter(TextFieldFilter.SPEC_UP_ALP+" ", 30, true));
        textField3.setFieldFilter(new TextFieldFilter(TextFieldFilter.SPEC_UP_ALP+" ", 30, true));

        add(paxWeight);
        add(deadLoads);
        add(zfwLimits);
        add(pantry);
        add(textField1);
        add(textField2);
        add(textField3);
        paxWeight.setPosition(new Point(80, 150));
        deadLoads.setPosition(new Point(80, 180));
        zfwLimits.setPosition(new Point(80, 210));
        pantry.setPosition(new Point(80, 240));
        textField1.setPosition(new Point(80, 270));
        textField2.setPosition(new Point(80, 300));
        textField3.setPosition(new Point(80, 330));
        setOrderList();

    }

    public void setPaxWeightValue(String s) {
        paxWeight.setText("PAX WEIGHT USED: " + s);
    }

    public void setDeadLoadsValue(String s) {
        deadLoads.setText("DEADLOADS IN HOLDS TTL: " + s);
    }

    public void setZfwLimits(String s) {
        zfwLimits.setText("ZFW LIMITS: " + s);
    }

    public void setPantryValue(String s) {
        pantry.setText("PANTRY: " + s);
    }

    public void setTextField1(String s) {
        textField1.setText(s);
    }

    public void setTextField2(String s) {
        textField2.setText(s);
    }

    public void setTextField3(String s) {
        textField3.setText(s);
    }

    public String getVsi1() {
        return paxWeight.getText();
    }

    public String getVsi2() {
        return deadLoads.getText();
    }

    public String getVsi3() {
        return zfwLimits.getText();
    }

    public String getVsi4() {
        return pantry.getText();
    }

    public String getVsi5() {
        return textField1.getText();
    }

    public String getVsi6() {
        return textField2.getText();
    }

    public String getVsi7() {
        return textField3.getText();
    }

    public void setOrderList() {
        Vector<Component> focusOrder = new Vector<Component>();
        focusOrder.add(textField1);
        focusOrder.add(textField2);
        focusOrder.add(textField3);
        MyOwnFocusTraversalPolicy travelsalPolicy = new MyOwnFocusTraversalPolicy(focusOrder);
        this.setFocusTraversalPolicy(travelsalPolicy);
        this.setFocusTraversalPolicyProvider(true);
        this.setFocusCycleRoot(true);
    }

    @Override
    public int getIdentity() {
        return identity;
    }

    public void firstFocused() {
        this.textField1.requestFocusInWindow();
    }

    public void reset(){
        this.textField1.setText("");
        this.textField2.setText("");
        this.textField3.setText("");
    }
}
